﻿using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using Blog.Core.Util;
using SqlSugar;

namespace Blog.Core
{
    public class EntityBase
    {
        public EntityBase()
        {
            Id = IdentityGenerator.NewId();

            if (string.IsNullOrEmpty(CreateUserId))
            {
                CreateUserId = Id;
            }
        }

        /// <summary>
        /// Id
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsNullable = false, Length = 36)]
        [MaxLength(36)]
        public virtual string Id { get; set; }

        /// <summary>
        /// 创建人Id
        /// </summary>
        [SugarColumn(IsNullable = true,Length = 36)]
        public virtual string CreateUserId { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(ColumnName = "CreateTime",IsNullable = false)]
        public virtual DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 修改时间
        /// </summary>
        [SugarColumn(ColumnName = "UpdateTime", IsNullable = false)]
        public virtual DateTime UpdateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 是否删除
        /// </summary>
        [SugarColumn(ColumnName = "IsDelete", IsNullable = false)]
        public virtual bool IsDelete { get; set; } 
    }
}